﻿using System;
using System.Collections.Generic;
using System.Linq;
using TuxedoLib;

namespace SpaceSquirrel.SpriteRenderers
{
	class AcornRenderer : SpriteRenderer
	{
		public override void Render(Sprite sprite, PlayScene scene, Image screen, int offsetX, int offsetY, int renderCounter)
		{
			int left = sprite.x + offsetX - 8;
			int top = sprite.y + offsetY - 8;
			
			string baze = "acorn";
			string mode = ((Automation.AcornAutomation)sprite.automation).mode;
			if (mode == "throwing" || mode == "baldpatrolling")
			{
				baze = "acorn_capless";
			}

			string path;
			if (sprite.moving)
			{
				path = baze + "_" + "13"[(renderCounter / 2) & 1];
			}
			else
			{
				path = baze + "_2";
			}

			path = "sprites/" + path + ".png";
			bool reverse = sprite.lastDirection == "left";
			Image img;
			if (reverse)
			{
				img = ImageLibrary.GetBackwardsImage(path);
			}
			else
			{
				img = ImageLibrary.GetImage(path);
			}

			screen.Blit(img, left, top);
		}
	}
}
